﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace json1.Domain
{
    public class DbInitializer
    {
        public static void Seed()
        {
            using (Admin2000DbContext db =new Admin2000DbContext())
            {
                db.Database.EnsureCreated();

                    var astudio = db.Studios.Any();

                    if (!astudio)
                    {
                        var staff = new Staffs
                        {
                            staffName = "员工",
                            Description = "就是员工啊"
                        };

                        db.Staffs.Add(staff);

                        db.SaveChanges();

                        db.Studios.Add(new studio
                        {
                            studioName = "工作室",
                            staffId = staff.id
                        });
                        db.SaveChanges();

                        db.Works.Add(new work
                        {
                            workName = "工作",
                            staffId = staff.id
                        });
                        db.SaveChanges();
                }
            }
        }
    }
}
